package com.spike.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SMSRabbitConfig {
    public final static String EXCHANGE_NAME = "SMSDirectExchange";
    public final static String QUEUE_NAME = "SMSDirectQueue";
//    配置交换机
    @Bean("exchange")
    public Exchange exchange(){
        return ExchangeBuilder.directExchange(EXCHANGE_NAME).build();
    }
    //    配置队列
    @Bean("queue")
    public Queue queue(){
        return QueueBuilder.durable(QUEUE_NAME).build();
    }
//    配置绑定
    @Bean
    public Binding binding(@Qualifier("queue") Queue queue,@Qualifier("exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("phone").noargs();
    }
}
